/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity.tx;

import entity.establishment.OutletFood;
import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 *
 * @author AdminNUS
 */
@Entity
public class OutletReservation implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @ManyToOne
    private Users customer;
    @ManyToOne
    private OutletFood outlet;
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar timeslot;
    @OneToOne
    private OutletSeatArea area;
    private Boolean confirmStatus;
    private Boolean customerShowUp;
    private String comments;
    private Integer tsTime;
    private Integer numPpl;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Users getCustomer() {
        return customer;
    }

    public void setCustomer(Users customer) {
        this.customer = customer;
    }

    public OutletFood getOutlet() {
        return outlet;
    }

    public void setOutlet(OutletFood outlet) {
        this.outlet = outlet;
    }

    public Calendar getTimeslot() {
        return timeslot;
    }

    public void setTimeslot(Calendar timeslot) {
        this.timeslot = timeslot;
    }

    public OutletSeatArea getArea() {
        return area;
    }

    public void setArea(OutletSeatArea area) {
        this.area = area;
    }

    public Boolean getConfirmStatus() {
        return confirmStatus;
    }

    public void setConfirmStatus(Boolean confirmStatus) {
        this.confirmStatus = confirmStatus;
    }
    
    public String getStatusStr(){
        if (confirmStatus == null)
            return "Unconfirmed";
        if (confirmStatus)
            return "Confirmed";
        else
            return "Unconfirmed";
    }

    public Boolean getCustomerShowUp() {
        return customerShowUp;
    }

    public void setCustomerShowUp(Boolean customerShowUp) {
        this.customerShowUp = customerShowUp;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public Integer getTsTime() {
        return tsTime;
    }
    
    public void setTsTime(Integer tsTime) {
        this.tsTime = tsTime;
    }

    public Integer getNumPpl() {
        return numPpl;
    }

    public void setNumPpl(Integer numPpl) {
        this.numPpl = numPpl;
    }
    
    public String getDateStr() {
        String[] months = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
        String[] weekDays = new String[]{"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
        Calendar t = (Calendar) timeslot.clone();
        String s = t.get(Calendar.DATE) + " " + months[t.get(Calendar.MONTH)] + ", "
                + t.get(Calendar.YEAR) + " (" + weekDays[t.get(Calendar.DAY_OF_WEEK)-1] + ")";
        return s;
    }

    public String getTimeStr() {
        Calendar t = (Calendar) timeslot.clone();
        String hour = String.valueOf(t.get(Calendar.HOUR_OF_DAY));
        String minute = String.valueOf(t.get(Calendar.MINUTE));
        if (hour.length()==1){
            hour = "0" + hour;
        }
        if (minute.length() == 1) {
            minute = "0" + minute;
        }
        String s = hour + ":" + minute;
        return s;
    }
    
}
